table of contents
GIT-FSCK(1) | Git Manual | GIT-FSCK(1) |
NAME¶
git-fsck - Verifies the connectivity and validity of the objects in the database
SYNOPSIS¶
git fsck [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
[--[no-]full] [--strict] [--verbose] [--lost-found] [<object>*]
DESCRIPTION¶
Verifies the connectivity and validity of the objects in the database.
OPTIONS¶
<object>
If no objects are given, git fsck defaults to using the index file, all SHA1 references in .git/refs/*, and all reflogs (unless --no-reflogs is given) as heads.
--unreachable
--root
--tags
--cache
--no-reflogs
--full
--strict
--verbose
--lost-found
It tests SHA1 and general object sanity, and it does full tracking of the resulting reachability and everything else. It prints out any corruption it finds (missing or bad objects), and if you use the --unreachable flag it will also print out objects that exist but that aren’t readable from any of the specified head nodes.
So for example
git fsck --unreachable HEAD \
$(git for-each-ref --format="%(objectname)" refs/heads)
will do quite a lot of verification on the tree. There are a few extra validity tests to be added (make sure that tree objects are sorted properly etc), but on the whole if git fsck is happy, you do have a valid tree.
Any corrupt objects you will have to find in backups or other archives (i.e., you can just remove them and do an rsync with some other site in the hopes that somebody else has the object you have corrupted).
Of course, "valid tree" doesn’t mean that it wasn’t generated by some evil person, and the end result might be crap. git is a revision tracking system, not a quality assurance system ;)
EXTRACTED DIAGNOSTICS¶
expect dangling commits - potential heads - due to lack of head information
missing sha1 directory <dir>
unreachable <type> <object>
missing <type> <object>
dangling <type> <object>
warning: git-fsck: tree <tree> has full pathnames in it
sha1 mismatch <object>
ENVIRONMENT VARIABLES¶
GIT_OBJECT_DIRECTORY
GIT_INDEX_FILE
GIT_ALTERNATE_OBJECT_DIRECTORIES
AUTHOR¶
Written by Linus Torvalds <torvalds@osdl.org[1]>
DOCUMENTATION¶
Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org[2]>.
GIT¶
Part of the git(1) suite
NOTES¶
- 1.
- torvalds@osdl.org
- 2.
- git@vger.kernel.org
02/03/2020 | Git 1.7.1 |